package com.lanzhou.yuanfen.diary.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lanzhou.yuanfen.diary.entity.Article;
import com.lanzhou.yuanfen.diary.mapper.ArticleMapper;
import com.lanzhou.yuanfen.diary.service.IArticleService;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author lcllge
 * @since 2020-05-23
 */
@Service
@CacheConfig(cacheNames = "test")
public class ArticleServiceImpl extends ServiceImpl<ArticleMapper, Article> implements IArticleService {

    @Resource
    private ArticleMapper articleMapper;

    @Override
    @Cacheable(value = "article", keyGenerator = "myKeyGenerator")
    public List<Article> redis() {
        return list();
    }

    @Override
    public Map<String, Long> getYFInfoByUserKey(String userKey) {
        return articleMapper.selectYFInfoByUserKey(userKey);
    }
}
